package com.example.feign.feign;


import com.example.feign.entity.Chapter;
import com.example.feign.feign.fallback.ChapterFallback;
import com.example.feign.util.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

@FeignClient(value = "BASE-SERVICE",fallback = ChapterFallback.class)
public interface ChapterFeign {

    @RequestMapping(
            value = "/chapter/get",
            method = RequestMethod.GET,
            consumes = "application/json")
    public Response getChapter(@RequestParam(value = "page",required = false) Integer page,
                              @RequestParam(value = "size",required = false) Integer size,
                              @RequestParam(value = "spId",required = true) String spId,
                              @RequestParam(value = "courseName",required = false) String courseName,
                              @RequestParam Map map);

    @RequestMapping(value = "/chapter/add",method = RequestMethod.POST)
    public Response addChapter(@RequestBody Chapter chapter);

    @RequestMapping(value = "/chapter/update",method = RequestMethod.PUT)
    public Response updateChapter(@RequestBody Chapter chapter);

    @RequestMapping(value = "/chapter/del",method = RequestMethod.PUT)
    public Response delChapter(@RequestParam(value = "chapterId", required = true) String chapterId);
}
